import type { ApiResult, Paging } from '../interface'

/**
 * 登录模块命名空间
 */
export namespace Login {
  export type ReqLoginForm = {
    username: string
    password: string
    validateCode: string
  }
  export type ResLogin = ApiResult & {
    token: string
    roles: string[]
    permissions: string[]
    name: string
    principal: string
    depts: string[]
    deptNames: string[]
  }
  export type ResAuthButtons = {
    [key: string]: string[]
  }
}

/**
 * 菜单模块命名空间
 */
export namespace Menu {
  export type MenuData = {
    name?: string
    target?: string
    id?: string
    title?: string
    menuUrl?: string
    priority?: number
    parentId?: string
    groupCode?: string
    isDisplay?: boolean
    status?: string
    extData?: string | MenuExtData
    childrens?: any[]
  }
  export type MenuExtData = {
    icon: string
    menuRouter: boolean
    type: number
    openType: number
    redirect: string
    affix?: boolean
    full?: boolean
    link?: string
    keepAlive?: boolean
    query?: string
  }
  export type MenuForm = MenuData & Paging & {}
  export type MenuOptions = MenuData & {
    type: number
    path: string
    children?: MenuOptions[]
    component: any
    meta: {
      menuRouter: boolean
      icon: string
      type: number
      openType: number
      title: string
      link: string
      hide: boolean
      full: boolean
      affix: boolean
      keepAlive: boolean
      query: string
    }
  }
}
/**
 * 系统模块命名空间
 */
export namespace Sys {
    /**
   * 组织结构数据树形模型
   */
  export type OrganizationData = {
    id?: string
    parentId?: string
    code?: string
    name?: string
    description?: string
    sortOrder?: number
    childrens?: any[]
  }
  /**
   * 组织结构数据模型
   */
  export type Organization = {
    id?: string
    parentId?: string
    code?: string
    name?: string
    description?: string
    sortOrder?: number
  }
  /**
   * 组织结构分页查询数据模型
   */
  export type OrganizationForm = Organization & Paging & any
  /**
   * 用户表数据模型
   */
  export type User = {
    userid?: string
    groupId?: string
    loginPwd?: string
    name?: string
    status?: number
    mail?: string
    mobileno?: string
    loginName?: string
    lastLoginIp?: string
    lastLoginTime?: string
    registerIp?: string
    registerTime?: string
    active?: boolean
  }
  /**
   * 用户表分页查询数据模型
   */
  export type UserForm = User &
    Paging & {
      keyword?: string
      roleCodes?: string[]
      orgIds?: string[]
      dataPerms?: string[]
      affirmPwd?: string
      oldpasswd?: string
    }
  /**
   * 行政区域信息表数据模型
   */
  export type Location = {
    id?: string
    name?: string
    parentId?: string
    orders?: number
    code?: string
    post?: string
    description?: string
  }
  /**
   * 行政区域信息表分页查询数据模型
   */
  export type LocationForm = Location & Paging & {}
  /**
   * 系统日志记录配置表数据模型
   */
  export type SysLogConf = {
    id?: string
    code?: string
    name?: string
    flag?: boolean
  }
  /**
   * 系统日志记录配置表分页查询数据模型
   */
  export type SysLogConfForm = SysLogConf & Paging & {}
  /**
   * 定时任务配置表数据模型
   */
  export type Crontab = {
    id?: string
    className?: string
    method?: string
    params?: string
    cron?: string
    enabled?: boolean
    remark?: string
  }
  /**
   * 定时任务配置表分页查询数据模型
   */
  export type CrontabForm = Crontab & Paging & {}
  /**
   * 访问权限表数据模型
   */
  export type Authorization = {
    id?: string
    code?: string
    name?: string
    description?: string
    parentId?: string
    children?: Authorization[]
    hasChildren?: boolean
  }
  /**
   * 访问权限表分页查询数据模型
   */
  export type AuthorizationForm = Authorization &
    Paging & {
      menuIds?: string[]
    }
  /**
   * 角色表数据模型
   */
  export type Role = {
    id?: string
    code?: string
    name?: string
    description?: string
    priority?: number
    msuper?: string
  }
  /**
   * 角色表分页查询数据模型
   */
  export type RoleForm = Role &
    Paging & {
      authCodes?: string[]
      userids?: string[]
      dataPerms?: string[]
    }
  /**
   * 数据权限信息数据模型
   */
  export type DataPermission = {
    id?: string
    name?: string
    description?: string
    type?: string
    perms?: string
    bizPattern?: string
  }
  /**
   * 数据权限信息分页查询数据模型
   */
  export type DataPermissionForm = DataPermission & Paging & {}
  /**
   * 系统参数配置数据模型
   */
  export type SystemParameter = {
    id?: string
    parameterKey?: string
    parameterValue?: string
    parameterName?: string
    parameterDescribe?: string
  }
  /**
   * 系统参数配置分页查询数据模型
   */
  export type SystemParameterForm = SystemParameter & Paging & {}
  /**
   * 系统日志记录表数据模型
   */
  export type SysLog = {
    id?: string
    logCode?: string
    startTime?: string
    endTime?: string
    useTime?: number
    result?: string
    userid?: string
    operateIp?: string
    stackTrace?: string
  }
  /**
   * 系统日志记录表分页查询数据模型
   */
  export type SysLogForm = SysLog & Paging & {}
  /**
   * 数字字典表数据模型
   */
  export type Dict = {
    id?: string
    name?: string
    code?: string
    groupCode?: string
    priority?: number
    disabled?: boolean
    parentCode?: string
  }
  /**
   * 数字字典表分页查询数据模型
   */
  export type DictForm = Dict & Paging & {}

  /**
   * 应用信息数据模型
   */
  export type App = {
    appid?: string
    secret?: string
    name?: string
    description?: string
    homePage?: string
    logo?: string
    userid?: string
    accept?: boolean
  }
  /**
   * 应用信息分页查询数据模型
   */
  export type AppForm = App &
    Paging & {
      perms?: string[]
    }
  /**
   * 数据库连接配置信息数据模型
   */
  export type DataSource = {
    id?: string
    code?: string
    name?: string
    jdbcUrl?: string
    userName?: string
    password?: string
    dbType?: string
    driver?: string
    maxWait?: number
    initSize?: number
    minIdle?: number
    testSql?: string
    maxActive?: string
    dataName?: string
    props?: Map<string, string>
  }
  /**
   * 数据库连接配置信息分页查询数据模型
   */
  export type DataSourceForm = DataSource & Paging & {}

  export type ResFileInfo = ApiResult & {
    file?: string
    url?: string
  }
  export type AuthorizationInfo = {
    token: string
    roles: string[]
    permissions: string[]
    name: string
    principal: string
    depts: string[]
    deptNames: string[]
  }
  /**
   * 自定义表单实例数据模型
   */
  export type DynaFormInst = {
    id?: string
    formId?: string
    code?: string
    name?: string
    refId?: string
    description?: string
    dataApi?: string
    storeApi?: string
    version?: number
    releaseBy?: string
    releaseTime?: string
    formType?: string
  }

  /**
   * 自定义表单实例分页查询数据模型
   */
  export type DynaFormInstForm = DynaFormInst & Paging & {}
  /**
   * 自定义表单数据模型
   */
  export type DynaForm = {
    id?: string
    code?: string
    name?: string
    content?: string
    refId?: string
    updatedTime?: string
    description?: string
    createdBy?: string
    createdTime?: string
    updatedBy?: string
    dataApi?: string
    storeApi?: string
    currentVersion?: number
    releaseTime?: string
    formType?: string
  }

  /**
   * 自定义表单分页查询数据模型
   */
  export type DynaFormForm = DynaForm & Paging & {}
  /**
   * 自定义列表页面数据模型
   */
  export type DynaListPage = {
    id?: string
    rowKey?: string
    code?: string
    name?: string
    content?: string
    updatedTime?: string
    description?: string
    createdBy?: string
    createdTime?: string
    updatedBy?: string
    searchApi?: string
    formId?: string
    removeApi?: string
    allowBtns?: number
  }

  /**
   * 自定义列表页面分页查询数据模型
   */
  export type DynaListPageForm = DynaListPage & Paging & {}
  /**
   * 查询页面表格字段排列顺序信息
   */
  export type TableColumnInfo = {
    fieldName: string
    title: string
    priority: number
    display: boolean
  }

  /**
   * 表字段信息
   */
  export type ColumnInfo = {
    name?: string
    objectName?: string
    remarks?: string
    pk?: boolean
    unique?: boolean
    nullable?: boolean
    decimalDigits?: number
    sqlType?: number
    sqlTypeName?: string
    javaTypeName?: string
    dataLength?: number
    defaultValue?: string
  }

  /**
   * 表外键信息
   */
  export type ForeignKey = {
    name?: string
    pkTableName?: string
    fkTableName?: string
    pkColumnName?: string
    fkColumnName?: string
  }

  /**
   * 表信息
   */
  export type TableInfo = {
    mappingName?: string
    name?: string
    remarks?: string
    primaryKeyColumns?: ColumnInfo[]
    allColumns?: ColumnInfo[]
    notKeyColumns?: ColumnInfo[]
    foreignKeyColumns?: ColumnInfo[]
    foreignKeys?: ForeignKey[]
  }

  /**
   * 自定义接口信息数据模型
   */
  export type DynaApiInfo = {
    id?: string
    apiTags?: string
    apiPath?: string
    apiMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'PATCH' | 'OPTIONS' | 'TRACE'
    apiSummary?: string
    apiDescription?: string
    apiParamerts?: string
    apiType?: string
    apiScript?: string
    apiSchema?: string
  }

  /**
   * 自定义接口信息数据模型
   */
  export type DynaApiInfoForm = DynaApiInfo & Paging & {}

  /**
   * 自定义数据模型
   */
  export type DynaDataModel = {
    id?: string
    name?: string
    code?: string
    superType?: string
    remark?: string
    tableName?: string
    fields?: DynaDataModelField[]
  }

  /**
   * 自定义数据模型字段信息
   */
  export type DynaDataModelField = {
    id?: string
    modelId?: string
    name?: string
    code?: string
    pk?: boolean
    dataType?: string
    remark?: string
    required?: boolean
    defaultValue?: string
    fieldName?: string
    priority?: number
  }

  /**
   * 角色首页显示的部件数据模型
   */
  export type RoleHomeComp = {
    id?: string
    roleCode?: string
    compId?: string
    priority?: number
    fixedDisplay?: number
  }

  /**
   * 个人代办查询配置数据模型
   */
  export type TodoListConfig = {
    id?: string
    title?: string
    priority?: number
    roleCode?: string
    type?: string
    url?: string
    props?: string
  }

  /**
   * 个人代办查询配置分页查询数据模型
   */
  export type TodoListConfigForm = TodoListConfig & Paging & {}

  /**
   * 系统首页部件配置信息数据模型
   */
  export type HomePageComp = {
    id?: string
    code?: string
    title?: string
    type?: 'comp' | 'iframe'
    width?: number
    height?: string
    fixedDisplay?: number
  }

  /**
   * 系统首页部件配置信息分页查询数据模型
   */
  export type HomePageCompForm = HomePageComp & Paging & {}

  /**
   * 用户待办事项
   */
  export type TodoItem = {
    target?: string
    title: string
    total: number
    url: string
  }

  /**
   * 个人首页显示部件配置数据模型
   */
  export type HomeCompConfig = {
    id?: string
    userId?: string
    compId?: string
    priority?: number
  }
  
  /**
	 * 系统附件信息数据模型
	 */
	export type AttachmentInfo = {
		id?: string
		fileName?: string
		mimeType?: string
		fileSize?: number
		filePath?: string
		creator?: string
		dataId?: string
		typeCode?: string
		createAt?: string
		createBy?: string
	}
	
	/**
	 * 系统附件信息分页查询数据模型
	 */
	export type AttachmentInfoForm = AttachmentInfo & Paging & {}

  /**
	 * 扩展字段属性信息数据模型
	 */
	export type ExtPropertyInfo = {
		id?: string
		name?: string
		className?: string
		groupCode?: string
		description?: string
    appid?:string
	}
	
	/**
	 * 扩展字段属性信息分页查询数据模型
	 */
	export type ExtPropertyInfoForm = ExtPropertyInfo & Paging & {}
}

/**
 * 服务器监控命名空间
 */
export namespace Monitor {
  export type AvailableTags = {
    tag: string
    values: string[]
  }
  export type Sample = {
    statistic: Statistic
    value: number
  }
  export enum Statistic {
    TOTAL = 'total',
    COUNT = 'count',
    MAX = 'max',
    VALUE = 'value',
    ACTIVE = 'active',
    DURATION = 'duration',
    UNKNOWN = 'unknown'
  }
  export type Metric = {
    name: string
    description?: string
    baseUnit: string
    measurements: Sample[]
    availableTags: AvailableTags[]
    value?: string
  }
  export type Request = {
    method: string
    uri: string
    headers: Map<string, string[]>
    remoteAddress: string
  }
  export type Response = {
    status: number
    headers: Map<string, string[]>
  }
  export type HttpTrace = {
    timestamp: string
    principal: string
    sessionId: string
    timeTaken: number
    request: Request
    response: Response
  }
  export type DiskInfo = {
    path: string
    baseUnit: string
    total: number | string
    name: string
    free: number | string
    useRate?: string
  }
}
